Thermo 18 Click
Thermo 18 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Luka FIlipovic
- Date : Aug 2021.
- Type : I2C type
Software Support
Example Description
The example application showcases ability of device to read temperature and detect and assert interrupt on undertemperature or overtemperature thresholds.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Thermo18
Example Key Functions
- thermo18_cfg_setup Config Object Initialization function.
void thermo18_cfg_setup(thermo18_cfg_t *cfg)
Thermo 18 configuration object setup function.
Thermo 18 Click configuration object.
Definition thermo18.h:169
- thermo18_init Initialization function.
err_t thermo18_init(thermo18_t *ctx, thermo18_cfg_t *cfg)
Thermo 18 initialization function.
Thermo 18 Click context object.
Definition thermo18.h:152
- thermo18_default_cfg Click Default Configuration function.
err_t thermo18_default_cfg(thermo18_t *ctx)
Thermo 18 default configuration function.
- thermo18_read_temperature Reads and calculates temperature value.
err_t thermo18_read_temperature(thermo18_t *ctx, float *temperature)
Reads and calculates temperature value.
- thermo18_set_temperature_threshold Sets temperature threshold.
err_t thermo18_set_temperature_threshold(thermo18_t *ctx, uint8_t threshold_reg, float threshold_limit)
Sets temperature threshold.
- thermo18_reset Resets device.
err_t thermo18_reset(thermo18_t *ctx)
Resets device.
Application Init
Initialization of communication modules and interrupt pin. Reads device ID to check comunication. Then resets device, and sets undertemperature and overtemperature thresholds on 24 and 30 degrees Celsius. In the end enables OneShot temperature conversion.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
uint8_t temp_data = 0;
log_printf( &logger, " > ID: 0x%.2X\r\n", ( uint16_t )temp_data );
{
log_error( &logger, " Device ID. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
{
log_error( &logger, " Default configuration. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_info( &logger, " Application Task " );
}
#define THERMO18_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition thermo18.h:139
#define THERMO18_REG_CTRL
Definition thermo18.h:76
#define THERMO18_REG_DEVICE_ID
Thermo 18 description register.
Definition thermo18.h:73
#define THERMO18_DEVICE_ID
Thermo 18 description setting.
Definition thermo18.h:114
#define THERMO18_CONTROL_ONESHOT_ENABLED
Thermo 18 control settings.
Definition thermo18.h:98
err_t thermo18_generic_read(thermo18_t *ctx, uint8_t reg, uint8_t *rx_data)
Thermo 18 I2C reading function.
err_t thermo18_generic_write(thermo18_t *ctx, uint8_t reg, uint8_t tx_data)
Thermo 18 I2C writing function.
void application_init(void)
Definition main.c:36
Application Task
Checks status to see if the temperature conversion is finished. When it's finished reads and logs calculated temperature data. Then checks if status is asserted for threshold detection, and logs if detected. In the end re-enables OneShot conversion.
{
uint8_t status;
{
float temp = 0.0;
log_printf( &logger, " > Temperature[degC]: %.2f\r\n", temp );
if ( 0 != status )
{
{
log_info( &logger, " Overtemperature Threshold detected." );
}
{
log_info( &logger, " Undertemperature Threshold detected." );
}
}
}
Delay_ms ( 300 );
}
#define THERMO18_REG_STATUS
Definition thermo18.h:77
#define THERMO18_STATUS_UNDERTEMPERATURE
Definition thermo18.h:108
#define THERMO18_STATUS_OVERTEMPERATURE
Definition thermo18.h:107
#define THERMO18_STATUS_DATA_BUSY
Definition thermo18.h:106
#define THERMO18_STATUS_DATA_READY
Thermo 18 description status values.
Definition thermo18.h:105
void application_task(void)
Definition main.c:91
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.